package tfc_editor.tests;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import tfc_editor.*;
import tfc_editor.GUI.FinestraLogIn;

/**
 * Clase que testeja el fer diferents logins.
 * @author Ismael Gonzalez Burgos
 *
 */
public class Test4 extends TestCase
{
	private Main app;

	/**
	 * Constructor de la clase.
	 * @param name Nom que rebem del JUnit.
	 */
	public Test4(String name)
	{
		super(name);
	}

	/**
	 * Funcio per a logejarse.
	 * @param login Login desitjat.
	 * @param password Password desitjat.
	 */
	public void LogIn(String login,String password)
	{
		FinestraLogIn fli = new FinestraLogIn(app.GetEditor().GetPastryManager(),app.GetEditor());
		fli.setVisible(true);
		fli.TestSetLoginIAccepta(login,password);
	}

	/**
	 * Funcio d'inicialitzacio de la clase de test.
	 */
	protected void setUp() 
	{
		System.out.println("[Test4] Strarting");
		System.out.println("[Test4] Test to diferent log ins.");
		
		try 
		{
			app = new Main();
			app.Start();
			LogIn("UsuariProva","PASSWORDP1");
			LogIn("Pep","asdf");			
			LogIn("Pau","catemo");			
			LogIn("Ramon","jarl");			
			LogIn("Manolo","rasputin");			
			LogIn("Ana","asdf");			
			LogIn("Maria","catemo");			
			LogIn("Klaus","jarl");			
			LogIn("Meïer","rasputin");			
			LogIn("Alejandro","rasputin");			
			LogIn("reasdfdf","asdf");			
			LogIn("jarl","catemo");			
			LogIn("alfa","jarl");			
			LogIn("beta","rasputin");
			LogIn("Maria2","catemo");			
			LogIn("Klaus2","jarl");			
			LogIn("Meïer2","rasputin");			
			LogIn("Alejandro2","rasputin");			
			LogIn("reasdfdf2","asdf");			
			LogIn("jarl2","catemo");			
			LogIn("alfa2","jarl");			
			LogIn("beta2","rasputin");
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * Funcio de finalitzacio del test.
	 */
	protected void tearDown()
	{
		System.out.println("[Test4] - Ending");
	}

	/**
	 * Funcio que crea el test.
	 * @return Instacia de la clase de test.
	 */
	public static Test suite()
	{
		return new TestSuite(Test4.class);
	}

	/**
	 * Funcio nula que ha de ser sobrecarregada del TestCase.
	 * @throws Exception Excepcio de fallada.
	 */
	public void testAbstractions() throws Exception 
	{

	}
}
